package com.ruoyi.material.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.material.domain.MateEvaluate;
import com.ruoyi.material.domain.MateQualified;
import com.ruoyi.material.mapper.MateQualifiedMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author
 * @Version 1.0
 */
@RestController
@RequestMapping("/matequalified")
public class MateQualifiedController extends BaseController {

    @Autowired
    MateQualifiedMapper mateQualifiedMapper;

    /*
      全部的合格供方名单
       */
    @GetMapping("/selectQualifiedList")
    public TableDataInfo selectQualifiedList(@RequestParam(value = "beginTime", required = false) String beginTime,
                                             @RequestParam(value = "endTime", required = false) String endTime) {

        startPage();
        MateQualified mateQualified = new MateQualified();
        mateQualified.setBeginTime(beginTime);
        mateQualified.setEndTime(endTime);
        mateQualified.setDeptId(SecurityUtils.getDeptId());
        List<MateQualified> qualifieds = mateQualifiedMapper.selectQualifiedList(mateQualified);
        return getDataTable(qualifieds);
    }

    /*
 查询已经做完的合格供方名单
  */
    @GetMapping("/selectEdit")
    public Map<String, Object> selectEdit(@RequestParam(value = "qualifiedId", required = false) Long qualifiedId) {
        Map<String, Object> result = new HashMap<>();
        MateQualified qualified = mateQualifiedMapper.selectEdit(qualifiedId);
        result.put("qualified", qualified);
        return result;
    }

}
